/**
 */
package js.backbone.impl;

import js.backbone.Attribute;
import js.backbone.BackbonePackage;
import js.backbone.DataType;

import js.impl.GlobalObjectImpl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Attribute</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link js.backbone.impl.AttributeImpl#getType <em>Type</em>}</li>
 *   <li>{@link js.backbone.impl.AttributeImpl#isRequired <em>Required</em>}</li>
 *   <li>{@link js.backbone.impl.AttributeImpl#isUniqueC <em>Unique C</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AttributeImpl extends GlobalObjectImpl implements Attribute {
	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final DataType TYPE_EDEFAULT = DataType.INT;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected DataType type = TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #isRequired() <em>Required</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isRequired()
	 * @generated
	 * @ordered
	 */
	protected static final boolean REQUIRED_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isRequired() <em>Required</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isRequired()
	 * @generated
	 * @ordered
	 */
	protected boolean required = REQUIRED_EDEFAULT;

	/**
	 * The default value of the '{@link #isUniqueC() <em>Unique C</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUniqueC()
	 * @generated
	 * @ordered
	 */
	protected static final boolean UNIQUE_C_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isUniqueC() <em>Unique C</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUniqueC()
	 * @generated
	 * @ordered
	 */
	protected boolean uniqueC = UNIQUE_C_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttributeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BackbonePackage.Literals.ATTRIBUTE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataType getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(DataType newType) {
		DataType oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BackbonePackage.ATTRIBUTE__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isRequired() {
		return required;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRequired(boolean newRequired) {
		boolean oldRequired = required;
		required = newRequired;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BackbonePackage.ATTRIBUTE__REQUIRED, oldRequired, required));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isUniqueC() {
		return uniqueC;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUniqueC(boolean newUniqueC) {
		boolean oldUniqueC = uniqueC;
		uniqueC = newUniqueC;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BackbonePackage.ATTRIBUTE__UNIQUE_C, oldUniqueC, uniqueC));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BackbonePackage.ATTRIBUTE__TYPE:
				return getType();
			case BackbonePackage.ATTRIBUTE__REQUIRED:
				return isRequired();
			case BackbonePackage.ATTRIBUTE__UNIQUE_C:
				return isUniqueC();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BackbonePackage.ATTRIBUTE__TYPE:
				setType((DataType)newValue);
				return;
			case BackbonePackage.ATTRIBUTE__REQUIRED:
				setRequired((Boolean)newValue);
				return;
			case BackbonePackage.ATTRIBUTE__UNIQUE_C:
				setUniqueC((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BackbonePackage.ATTRIBUTE__TYPE:
				setType(TYPE_EDEFAULT);
				return;
			case BackbonePackage.ATTRIBUTE__REQUIRED:
				setRequired(REQUIRED_EDEFAULT);
				return;
			case BackbonePackage.ATTRIBUTE__UNIQUE_C:
				setUniqueC(UNIQUE_C_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BackbonePackage.ATTRIBUTE__TYPE:
				return type != TYPE_EDEFAULT;
			case BackbonePackage.ATTRIBUTE__REQUIRED:
				return required != REQUIRED_EDEFAULT;
			case BackbonePackage.ATTRIBUTE__UNIQUE_C:
				return uniqueC != UNIQUE_C_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type: ");
		result.append(type);
		result.append(", required: ");
		result.append(required);
		result.append(", uniqueC: ");
		result.append(uniqueC);
		result.append(')');
		return result.toString();
	}

} //AttributeImpl
